<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>vue学习使用</title>
  <!-- 第1步： 引入vue库文件 -->
  <script src="./js/vue.js"></script>
  <style>
    .active {
      color: red;
      transition: all 2s;
    }
  </style>
</head>

<body>
  <!-- 第2步：挂载点 -->
  <div id="app">
    <ul>
      <li @click="setNav('a')" :class="{active:a}">aaa</li>
      <li @click="setNav('b')" :class="{active:b}">bbb</li>
      <li @click="setNav('c')" :class="{active:c}">ccc</li>
    </ul>
    <ul>
      <li v-if="a">11111</li>
      <li v-if="b">22222</li>
      <li v-if="c">33333</li>
    </ul>
  </div>

  <!-- 第3步：实例化vue -->
  <script>
    const vm = new Vue({
      el: '#app',
      data: {
        a: true,
        b: false,
        c: false
      },
      methods: {
        setNav(attrName) {
          this.a = false
          this.b = false
          this.c = false
          this[attrName] = true
        }
      }
    })
  </script>

</body>

</html>